package homework7_15;

import java.util.Arrays;

public class ShellSort {
	public static void main(String[] avgs){
		int[] a={5,3,7,2,9,8,1,4};
		shellSort(a);
		System.out.println(Arrays.toString(a));
	}
	public static void shellSort(int[] a) {
	    int n = a.length;
	    for (int gap = n / 2; gap > 0; gap /= 2) {
	        for (int i = gap; i < n; i++) {
	            int temp = a[i];
	            int j = i;
	            while (j >= gap && a[j - gap] > temp) {
	                a[j] = a[j - gap];
	                j -= gap;
	            }
	            a[j] = temp;
	        }
	    }
	}

}
